package com.yvtian.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yvtian.admin.pojo.SysDictDataEntity;
import com.yvtian.admin.dao.SysDictDataMapper;
import com.yvtian.admin.service.SysDictDataService;
import com.yvtian.utils.StringHelper;
import org.springframework.stereotype.Service;

/**
 * 字典数据表(sys_dict_data)表服务实现类
 *
 * @author long
 * @since 2024-04-17 09:12:21
 */
@Service("sysDictDataService")
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictDataEntity> implements SysDictDataService {

    @Override
    public IPage<SysDictDataEntity> findByPage(Page<SysDictDataEntity> page, SysDictDataEntity sysDictDataEntity) {
        LambdaQueryWrapper<SysDictDataEntity> queryWrapper = new LambdaQueryWrapper<>();
        if (StringHelper.isNotEmpty(sysDictDataEntity.getDictType())) {
            queryWrapper.eq(SysDictDataEntity::getDictType, sysDictDataEntity.getDictType());
        }
        if (StringHelper.isNotEmpty(sysDictDataEntity.getDictLabel())) {
            queryWrapper.like(SysDictDataEntity::getDictLabel, sysDictDataEntity.getDictLabel());
        }
        queryWrapper.orderByAsc(SysDictDataEntity::getDictSort);
        return this.page(page, queryWrapper);
    }
}

